.model small

MPrintString macro string
	push ax
	push dx
	mov ah,09h
		mov dx,offset string
	int 21h
	pop dx
	pop ax
endm

.stack
.data
; CONST
	machten10 dw 1000, 100, 10, 1
	endl db 10, 13, '$'
	up = 72		; second ascii code of arrows
	right = 77
	down = 80
	left = 75
	going_up db "Up we go...$"
	going_right db "All right...$"
	going_down db "Going down...$"
	going_left db "Turning left...$"
.code
.startup
mainloop:
	mov ah, 07h			; character input
		int 21h			; waits until key in keyboardbuffer
	test al, 0FFh		; if first char in buffer 0, potential arrow
	jnz notanarrow
	mov ah, 07h			; if arrow then second char in buffer
		int 21h			; check this second char
	mov bl, al
; uparrow:
	cmp bl, up			; if arrow up
	jnz rightarrow
		MPrintString going_up
		MPrintString endl
rightarrow:
	cmp bl, right		; else if arrow right
	jnz downarrow
		MPrintString going_right
		MPrintString endl
downarrow:
	cmp bl, down		; else if arrow down
	jnz leftarrow
		MPrintString going_down
		MPrintString endl
leftarrow:
	cmp bl, left		; else if arrow left
	jnz mainloop
		MPrintString going_left
		MPrintString endl
	jmp mainloop
notanarrow:
	cmp al, 27			; exit if esc (ascii 27)
	jnz mainloop
.exit
end